motion_add

语法:

motion_add(dir, speed);


参数 描述
dir The added direction.
speed The added speed.


返回: N/A(无返回值)


描述

This function add to the direction and a movement speed of an instance, and can be very useful for collisions and simple physics.


例如:

var pdir;
pdir = point_direction(other.x, other.y, x, y);
motion_add(pdir, other.speed);
if speed > 8 speed = 8;

the above code would be called in the collision event with another object. It adds to the direction of motion and the speed of the instance a vector based on the position and speed of the other instance involved in the collision. It then limits the speed if it goes over 8 (pixels per step).